package com.youan.log.modules.audit.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.youan.log.modules.audit.entity.RegionData;
import com.youan.log.modules.audit.service.IRegionDataService;
import com.youan.log.modules.audit.vo.RegionDataVO;
import io.swagger.annotations.ApiOperation;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author youan-autocode
 * @since 2021-03-04
 */
@RestController
@RequestMapping("/audit/region-data")
public class RegionDataController {

    @Autowired
    private IRegionDataService regionDataService;

    /**
     * 分页
     */
    @GetMapping("/page")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入importRecord")
    public R<IPage<RegionDataVO>> page(RegionDataVO regionData, Query query) throws Exception {
        IPage<RegionDataVO> pages = regionDataService.selectRegionData(Condition.getPage(query), regionData);
        return R.data(pages);
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入importRecord")
    public R<RegionData> detail(Long id, String tableSuffix) throws Exception {
        RegionData regionData = regionDataService.detail(id, tableSuffix);
        return R.data(regionData);
    }

    /**
     * 攻击与被攻击的分页查询
     */
    @GetMapping("/attack-attacked-page")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入importRecord")
    public R<IPage<RegionDataVO>> attackAndAttackedPage(RegionDataVO regionData, Query query) throws Exception {
        IPage<RegionDataVO> pages = regionDataService.selectAttackAndAttackedRegionData(Condition.getPage(query), regionData);
        return R.data(pages);
    }

}
